function pay(type, pay_id) {
    var pay_url =payAddress+ $api.getStorage('cfnetppuid') + '/' + pay_id + '/' + type + '.html';
    if (type === PAY_TYPE.PAY_AFTER) {
        api.ajax({
            url: pay_url,
            method: 'post',
            data: {
                values: {
                    return_type: 'json'
                }
            }
        }, function (ret, err) {
            if (ret.code == 200) {
                api.sendEvent({
                    name: 'aliPayResult',
                    extra: {
                        code: "4000"
                    }
                });
                toast("申请成功");
            }
        });
    } else {
        pay_url += '?is_wap=1';
        api.openWin({useWKWebView:true,
            name: 'webAliPay',
            url: pay_url
        });
    }
}
var PAY_TYPE={
    PAY_ALI:2,//支付宝
    PAY_AFTER:1//线下支付
};
var PAYSTATUS = {
    PAY_ERROR: -1,//错误
    PAY_AUDITING: 0,//待审核
    PAY_SUCCESS: 1,//成功
    PAY_WAIT:2//等待到账
};

function getPayStatus(id, cate, callback) {
    cfnetppPOST(url_train_orderState, {
        typeid: id,
        cate: cate,
        uid: $api.getStorage('cfnetppuid')
    }, false, function (ret, status) {
        //0=待支付,1=等待到账,2=等待审核,3=支付完成,4=订单失效,5=订单关闭,6=支付失败,7=审核通过',
        if (ret.code === 200) {
            switch (ret.data.status) {
                case 3:
                case 7:
                    callback(PAYSTATUS.PAY_SUCCESS);
                    break;
                case 2:
                    callback(PAYSTATUS.PAY_AUDITING);
                    break;
                case 1:
                    callback(PAYSTATUS.PAY_WAIT);
                    break;
                default:
                    callback(PAYSTATUS.PAY_ERROR);
            }
        } else
            callback(PAYSTATUS.PAY_ERROR);
    });
}